<template>
  <div>
    <CodeCard v-bind="btnDesc">
      <sdn-form ref="form" :model="form" labsdn-width="80px">
        <sdn-form-item label="活动名称">
          <sdn-input v-model="form.name"></sdn-input>
        </sdn-form-item>
        <sdn-form-item label="活动区域">
          <sdn-select v-model="form.region" placeholder="请选择活动区域">
            <sdn-option label="区域一" value="shanghai"></sdn-option>
            <sdn-option label="区域二" value="beijing"></sdn-option>
          </sdn-select>
        </sdn-form-item>
        <sdn-form-item label="活动时间">
          <sdn-col :span="11">
            <sdn-date-picker type="date" placeholder="选择日期" v-model="form.date1" style="width: 100%;"></sdn-date-picker>
          </sdn-col>
          <sdn-col class="line" :span="2">-</sdn-col>
          <sdn-col :span="11">
            <sdn-time-picker placeholder="选择时间" v-model="form.date2" style="width: 100%;"></sdn-time-picker>
          </sdn-col>
        </sdn-form-item>
        <sdn-form-item label="即时配送">
          <sdn-switch v-model="form.delivery"></sdn-switch>
        </sdn-form-item>
        <sdn-form-item label="活动性质">
          <sdn-checkbox-group v-model="form.type">
            <sdn-checkbox label="美食/餐厅线上活动" name="type"></sdn-checkbox>
            <sdn-checkbox label="地推活动" name="type"></sdn-checkbox>
            <sdn-checkbox label="线下主题活动" name="type"></sdn-checkbox>
            <sdn-checkbox label="单纯品牌曝光" name="type"></sdn-checkbox>
          </sdn-checkbox-group>
        </sdn-form-item>
        <sdn-form-item label="特殊资源">
          <sdn-radio-group v-model="form.resource">
            <sdn-radio label="线上品牌商赞助"></sdn-radio>
            <sdn-radio label="线下场地免费"></sdn-radio>
          </sdn-radio-group>
        </sdn-form-item>
        <sdn-form-item label="活动形式">
          <sdn-input type="textarea" v-model="form.desc"></sdn-input>
        </sdn-form-item>
        <sdn-form-item>
          <sdn-button type="primary" @click="onSubmit">立即创建</sdn-button>
          <sdn-button>取消</sdn-button>
        </sdn-form-item>
      </sdn-form>
      <template #annotation></template>
    </CodeCard>
  </div>
</template>

<script>


export default {
  components: {
    
  },
  methods: {
    onSubmit() {
      console.log('submit!');
    }
  },
  data() {
    return {
      form: {
        name: '',
        region: '',
        date1: '',
        date2: '',
        delivery: false,
        type: [],
        resource: '',
        desc: ''
      }
    }
  },
  setup() {
    const btnDesc = {
      title: "Form 表单",
      describe: "由输入框、选择器、单选框、多选框等控件组成，用以收集、校验、提交数据",
      codeBlock:`<sdn-form ref="form" :model="form" labsdn-width="80px">
        <sdn-form-item label="活动名称">
          <sdn-input v-model="form.name"></sdn-input>
        </sdn-form-item>
        <sdn-form-item label="活动区域">
          <sdn-select v-model="form.region" placeholder="请选择活动区域">
            <sdn-option label="区域一" value="shanghai"></sdn-option>
            <sdn-option label="区域二" value="beijing"></sdn-option>
          </sdn-select>
        </sdn-form-item>
        <sdn-form-item label="活动时间">
          <sdn-col :span="11">
            <sdn-date-picker type="date" placeholder="选择日期" v-model="form.date1" style="width: 100%;"></sdn-date-picker>
          </sdn-col>
          <sdn-col class="line" :span="2">-</sdn-col>
          <sdn-col :span="11">
            <sdn-time-picker placeholder="选择时间" v-model="form.date2" style="width: 100%;"></sdn-time-picker>
          </sdn-col>
        </sdn-form-item>
        <sdn-form-item label="即时配送">
          <sdn-switch v-model="form.delivery"></sdn-switch>
        </sdn-form-item>
        <sdn-form-item label="活动性质">
          <sdn-checkbox-group v-model="form.type">
            <sdn-checkbox label="美食/餐厅线上活动" name="type"></sdn-checkbox>
            <sdn-checkbox label="地推活动" name="type"></sdn-checkbox>
            <sdn-checkbox label="线下主题活动" name="type"></sdn-checkbox>
            <sdn-checkbox label="单纯品牌曝光" name="type"></sdn-checkbox>
          </sdn-checkbox-group>
        </sdn-form-item>
        <sdn-form-item label="特殊资源">
          <sdn-radio-group v-model="form.resource">
            <sdn-radio label="线上品牌商赞助"></sdn-radio>
            <sdn-radio label="线下场地免费"></sdn-radio>
          </sdn-radio-group>
        </sdn-form-item>
        <sdn-form-item label="活动形式">
          <sdn-input type="textarea" v-model="form.desc"></sdn-input>
        </sdn-form-item>
        <sdn-form-item>
          <sdn-button type="primary" @click="onSubmit">立即创建</sdn-button>
          <sdn-button>取消</sdn-button>
        </sdn-form-item>
      </sdn-form>`,
      attrs: [
        {
          "name": "type",
          "describe": "类型",
          "type": "string",
          "emun": "success/info/warning/danger",
          "default": "—"
        }, {
          "name": "closable",
          "describe": "是否可关闭",
          "type": "boolean",
          "emun": "—",
          "default": "FALSE"
        }, {
          "name": "disable-transitions",
          "describe": "是否禁用渐变动画",
          "type": "boolean",
          "emun": "—",
          "default": "FALSE"
        }, {"name": "hit", "describe": "是否有边框描边", "type": "boolean", "emun": "—", "default": "FALSE"}, {
          "name": "color",
          "describe": "背景色",
          "type": "string",
          "emun": "—",
          "default": "—"
        }, {
          "name": "size",
          "describe": "尺寸",
          "type": "string",
          "emun": "medium / small / mini",
          "default": "—"
        }, {"name": "effect", "describe": "主题", "type": "string", "emun": "dark / light / plain", "default": "light"}],
      events: [
        {"name": "click", "describe": "点击 Tag 时触发的事件", "params": "—"}, {
          "name": "close",
          "describe": "关闭 Tag 时触发的事件",
          "params": "—"
        }]
    };
    return {
      btnDesc,
    };
  },
};
</script>

<style scoped>
.demo {
  margin-bottom: 0.1rem;
  max-width: 50%;
}
</style>
